import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import resolveExternalsPlugin from "vite-plugin-resolve-externals";

// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  plugins: [
    vue(),
    vueJsx(),
    resolveExternalsPlugin({
      AMap: "AMap",
    }),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
      "vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js",
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: '@import "./src/assets/css/_handle.scss";',
      },
    },
  },
  server: {
    lintOnSave: true,
    host: "localhost",
    cors: true,
    open: true,
    hmr: true,
  },
});
